/*
 * GameLogic.cpp
 * Author: Johan Kristins
 *	
 */

#include "GameLogic.h"
#include "Context.h"

GameLogic::GameLogic()
{

};

GameLogic::~GameLogic()
{

};

bool GameLogic::Init()
{
	Entity* TestEnt = new Entity();
	//Load the geometry
	TestEnt->m_p3DObject->m_pMesh = Context::GetHandle()->m_pMeshMgr->LoadMesh("astroid_S.msh");
	TestEnt->m_xOrientation.loadIdentity();
	//Load diffuse texture
	TestEnt->m_p3DObject->m_pTexture = Context::GetHandle()->m_pTextureMgr->LoadTexture("planetaria_astroTex.tga");

	m_veRenderList.push_back(TestEnt);

	return true;
};

void GameLogic::Run()
{
	std::vector<Entity*>::iterator entity_iter = m_veRenderList.begin();
	while(entity_iter != m_veRenderList.end())
	{
		
		entity_iter++;
	};


};

void GameLogic::Close()
{

};

void GameLogic::OnKeyDown(char cKey)
{
	if (cKey == 'W')
	{
		m_cam.MoveUp(MOVE_SPEED);
	}
	else if (cKey == 'S')
	{
		m_cam.MoveDown(MOVE_SPEED);
	}
	else if (cKey == 'A')
	{
		m_cam.MoveLeft(MOVE_SPEED);
	}
	else if (cKey == 'D')
	{
		m_cam.MoveRight(MOVE_SPEED);
	}
	else if (cKey == 'Q')
	{
		m_cam.MoveForward(MOVE_SPEED);
	}
	else if (cKey == 'E')
	{
		m_cam.MoveBackward(MOVE_SPEED);
	};
};

void GameLogic::OnLeftMouseButtonDown(float x, float y)
{

}